﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _2
{
    internal class Account
    {
        public string AccountNumber { get; private set; }
        public decimal Balance { get; set; }

        public Account(string accountNumber, decimal initialBalance)
        {
            AccountNumber = accountNumber;
            Balance = initialBalance;
        }

        public virtual void Deposit(decimal amount)
        {
            Balance += amount;
        }

        public virtual decimal Withdraw(decimal amount)
        {
            if (amount > Balance)
                throw new InvalidOperationException("余额不足");
            Balance -= amount;
            return amount;
        }
    }
}
